home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0669.ZIP / LOGON.PRG < prev    next >
Text File  |  1985-12-30  |  3KB  |  111 lines

  1. * PROGRAM....LOGON.PRG
  2. * AUTHOR.....MIKE COTICCHIO
  3. * NOTES......This program permits logging on to password protected
  4. *            system and keeps a record of logon/logoff time
  5.  
  6. use logon index logon
  7. clear
  8.  
  9. **** Loop to test whether username is valid ****
  10. store .f. to goodname
  11. do while .not. goodname
  12.  clear 
  13.  store space(15) to username
  14.  @ 5,5 say "Username: " get username picture '@!'
  15.  read
  16.  
  17. **** If no username is input, program ends ****
  18.  
  19.  if asc(username) = 32
  20.   clear
  21.   close database
  22.   return
  23.  endif
  24.  
  25. **** Search for username.  If no match, give error message ****
  26. **** and loop back to start of routine                     ****
  27.  
  28.  find &username
  29.  if eof()
  30.   ? chr(7)
  31.   @ 10,5 say trim(username)+' is not on file!'
  32.   ?
  33.   ?
  34.   wait
  35.   loop
  36.  else
  37.   store .t. to goodname
  38.  endif
  39. enddo
  40. store trim(password) to password1
  41.  
  42. **** This section calls decryption routine.  Remove if not needed ****
  43.  
  44. @ 7,5 say 'Standby...'
  45. store space(10) to decrypted
  46. do decrypt with password1,decrypted
  47. store decrypted to password1
  48. @ 7,0 clear
  49.  
  50. **** End of call to decryption routine ****
  51.  
  52. store 0 to logtry
  53. store 5 to row
  54.  
  55. **** Loop to allow three tries at logging on before dumping out ****
  56.  
  57. do while logtry < 3
  58.  row = row+2
  59.  @ row,5 say 'Password?'
  60.  set color to 0/0
  61.  accept to mpassword
  62.  set color to 3/0
  63.  if upper(mpassword) <> upper(password1)
  64.   ? chr(7)
  65.   logtry = logtry+1
  66.  else
  67.   exit
  68.  endif
  69. enddo
  70. if logtry = 3
  71.  @ row+2,5 say "Strike three - you're out!"
  72.  ?
  73.  ?
  74.  wait
  75.  quit
  76. else
  77.  @ row+2,5 say 'Logon successful - welcome!'
  78.  ?
  79.  ?
  80. endif
  81. select 2
  82. use syslog
  83. append blank
  84. replace name with a->name,date with date()
  85. replace timein with substr(time(),1,5)
  86.  ?  'User '+trim(name)+' logged on system at '+ timein
  87.  
  88. close databases
  89.  
  90. **** time delay loop so you can read the message ****
  91.  
  92. store 0 to cntr
  93. do while cntr < 20
  94.  cntr = cntr+1
  95. enddo
  96.  
  97. **** At this point, you can call the main program, usually by    ****
  98. **** displaying a main menu of options.  In order for the logoff ****
  99. **** section to work, the program must exit back to this calling ****
  100. **** program by issuing a RETURN statement in response to an     ****
  101. **** option to end the program.  The program called below is a   ****
  102. **** sample menu                                                 ****
  103.  
  104. do mainmenu
  105. use syslog
  106. go bottom
  107. clear
  108. replace timeout with substr(time(),1,5)
  109. @ 10,5 say 'User '+trim(name)+' logged off system at '+timeout
  110. close databases
  111. return